package com.coderedma.core.io;

/**
 * @Author coderedma
 * @Desc 默认的资源加载器
 * @createTime 2024/7/29 14:51
 * @since 1.0.0
 */
public class DefaultResourceLoader implements ResourceLoader{

    public static final String CLASSPATH_URL_PREFIX = "classpath:";

    @Override
    public Resource getResource(String location) {
        // 判断是不是类加载路径
        if (location.startsWith(CLASSPATH_URL_PREFIX)) {
            return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()));
        }else { // 否则当成文件路径来获取
            return new FileSystemResource(location);
        }
    }
}
